<template>
    <div>
        <h1>智慧社区管理登录1</h1>
        <table border="">
            <tr>
                <td>账号</td>
                <td><input type="text" v-model="state.lname"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" v-model="state.lpwd"></td>
            </tr>
           
            <tr>
                <td>
                    <input type="button" value="登录" @click="add">
                </td>
                <td></td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import { reactive, onMounted, toRefs } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import axios from 'axios'
const router = useRouter()
const route = useRoute()
const data = reactive({
    state: {
        lname: '',
        lpwd: '',
      

    },
  

})

const { state } = toRefs(data)




const add = () => {
    if(state.value.lname == '') {
        alert("账号不能为空")
        return
    }
    if(state.value.lpwd == '') {
        alert("密码不能为空")
        return
    }
        
   
    axios({
        url: 'https://localhost:7046/api/Login/loginadd',
        method: 'get',
        params: state.value
    })
        .then(res => {
           if(res.data.data==-2)
           {
            alert("账号不存在")
            return
           }
           if(res.data.data==-3)
           {
            alert("密码错误")
            return
           }
           alert("登录成功")
           router.push('/Membershow')
           
        })
}





</script>

<style scoped></style>